#pragma once

#include "Containers/ForwardLinkedList.h"
class RObject;
class CType;

//类型的垃圾回收接口
class IGarbageCollectable
{

public:
    virtual ~IGarbageCollectable() = default;

    //收集指定对象引用的对象,如果引用了多次，就会重复添加
    virtual void CollectReferencedObjects(
        void* InInstance,
        TForwardForwardLinkedList<RObject*>& OutReferencedObjects
    ) = 0;

};

//基于遍历字段的垃圾回收接口实现
class CPropertyGarbageCollectable : public IGarbageCollectable
{

protected:
    CType* Type;
public:

    CPropertyGarbageCollectable(CType* InType)
        :Type(InType)
    {
    }

    virtual void CollectReferencedObjects(
        void* InInstance,
        TForwardForwardLinkedList<RObject*>& OutReferencedObjects
    ) override;
};